package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.ProcessStepService;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.ProcessStep;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author: DuYaTao
 * @ Date: 2025/9/18 - 15:14
 */
@RestController
@RequestMapping("/processStep")
public class ProcessStepController {

    @Autowired
    private ProcessStepService processStepService;

    @GetMapping("/page")
    public Result<PageInfo<ProcessStep>> page(ProcessStep processStep , @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int size){

        return processStepService.getProcessStepByPage(processStep,pageNum,size);
    }

    @GetMapping("/get/{id}")
    public Result<ProcessStep> getProcessStepById(@PathVariable Integer id){
        return processStepService.getProcessStepById(id);
    }

    @PostMapping("/add")
    public Result<ProcessStep> insert(@RequestBody ProcessStep processStep){
        return processStepService.insert(processStep);
    }

    @PutMapping("/update")
    public Result<ProcessStep> update(@RequestBody ProcessStep processStep){
        return processStepService.update(processStep);
    }

    @DeleteMapping("/delete/{id}")
    public Result<ProcessStep> deleteById(@PathVariable Integer id){
        return processStepService.deleteById(id);
    }
}
